package com.huawei.appgallery.wishwall.widget.dldbtn;

import android.content.Context;
import android.text.TextUtils;
import android.util.AttributeSet;
import com.huawei.appgallery.foundation.card.base.bean.BaseDistCardBean;
import com.huawei.appgallery.foundation.ui.framework.widget.button.ButtonFactory;
import com.huawei.appgallery.foundation.ui.framework.widget.button.DownloadButton;
import o.cdb;
import o.cdg;
import o.cke;
import o.ckk;
import o.ddq.f;
import o.dej;
import o.Logger;
import o.ContentManager;

public class WishWallDldButton extends DownloadButton {
    private String ॱॱ;

    public static class d {
        private static d ˋ = null;
        private String ˊ;
        private BaseDistCardBean ˏ = null;

        private d() {
        }

        public static synchronized d ˊ() {
            d dVar;
            synchronized (d.class) {
                if (ˋ == null) {
                    ˋ = new d();
                }
                dVar = ˋ;
            }
            return dVar;
        }

        public synchronized BaseDistCardBean ˏ() {
            return this.ˏ;
        }

        public synchronized void ˋ(BaseDistCardBean baseDistCardBean) {
            this.ˏ = baseDistCardBean;
        }

        public synchronized String ˋ() {
            return this.ˊ;
        }

        public synchronized void ˏ(String str) {
            this.ˊ = str;
        }
    }

    static {
        ButtonFactory.ˏ(WishWallDldButton.class, dej.class);
    }

    public WishWallDldButton(Context context) {
        super(context);
        this.ॱॱ = null;
    }

    public WishWallDldButton(Context context, AttributeSet attributeSet) {
        this(context, attributeSet, 0);
    }

    public WishWallDldButton(Context context, AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
        this.ॱॱ = null;
    }

    public synchronized String ᐝ() {
        return this.ॱॱ;
    }

    public synchronized void setCardId(String str) {
        this.ॱॱ = str;
    }

    public void setParam(BaseDistCardBean baseDistCardBean) {
        super.setParam(baseDistCardBean);
        setCardId(baseDistCardBean.ˋ());
    }

    public void setDownloadProgress(int i) {
        String ˋ = d.ˊ().ˋ();
        Object ᐝ = ᐝ();
        if (!TextUtils.isEmpty(ᐝ) && ᐝ.equals(ˋ)) {
            super.setDownloadProgress(i);
        }
    }

    public cke ॱ() {
        ai_();
        if (!ʼ()) {
            ˏ(true);
        }
        if (this.ˏ == null) {
            Logger.e("WishWallDldButton", "refreshStatus error:cardBean is null");
            return cke.ˊ;
        } else if (this.ˏ.ͺ() == 1 || this.ˏ.ॱـ() != null) {
            try {
                if (((cdg) cdb.ॱ(cdg.class)).ˎ(this.ˏ.ॱـ(), Integer.parseInt(this.ˏ.ˎˎ()))) {
                    return ˋ(cke.ˎ, f.ˊ);
                }
            } catch (Exception e) {
                Logger.e("WishWallDldButton", "refreshStatus, e : " + e.toString());
            }
            Object ˋ = d.ˊ().ˋ();
            String ᐝ = ᐝ();
            if (TextUtils.isEmpty(ˋ) || !ˋ.equals(ᐝ)) {
                return ˋ(cke.ˋ, f.ˋ);
            }
            return super.ॱ();
        } else {
            Logger.e("WishWallDldButton", "refreshStatus error:getPackage_ is null");
            return cke.ˊ;
        }
    }

    private cke ˋ(cke o_cke, int i) {
        this.ˎ = o_cke;
        this.ˋ = ContentManager.getInstant().getContext().getString(i);
        this.ॱ = -1;
        ckk ॱ = this.ʽ.ॱ(this.ˎ);
        ˋ(ॱ);
        ˋ(ॱ.ˏ(), this.ॱ);
        if (ॱ.ˊ() != 0) {
            setTextColor(ॱ.ˊ());
        }
        setText(this.ˋ);
        setProgress(this.ॱ);
        ˎ();
        setContentDescription(this.ˋ);
        return this.ˎ;
    }
}
